<?php echo $this->element('displayHeader'); ?>
<div class="toolbar"><?php echo $this->element('toolbar', array('buttons' => array('add', 'search', 'refresh'))); ?></div>

<?php if (empty($this->data)) : // ถ้าไม่มีข้อมูล ?>
<?php echo $this->element('dataNotFound'); ?>
<? else : // ถ้ามีข้อมูล ?>
    <?php echo $this->element('dataCaptionLimit'); ?>
    <?php $paginator->options(array('update' => 'content', 'indicator' => 'indicator')); ?>
    <?php $cur = $paginator->counter(array('format' => '%start%')); ?>

<table class="data">
    <thead>
        <tr>
            <th class="no"><?php echo $paginator->sort('No', 'Supplier.id'); ?></th>
            <th width="80px"><?php echo $paginator->sort('Code', 'Supplier.code'); ?></th>
            <th><?php echo $paginator->sort('Name', 'Supplier.name'); ?></th>
            <th class="collect_date"><?php echo $paginator->sort('Collect Date', 'modified'); ?></th>
            <th class="collector"><?php echo $paginator->sort('Collector', 'User.name'); ?></th>
            <th width="50px">&nbsp;</th>
        </tr>
    </thead>
    <tbody>
            <?php foreach($this->data as $key => $data): ?>
                <?php
                $tableCell = array();
                $tableCell[] = $cur++;
                $tableCell[] = $html->tag('span', $data['Supplier']['code'] .
                        ($data['Supplier']['special_part_no'] == true? $html->tag('span', '*', array('class' => "caption")): ''),
                        ($data['Supplier']['special_part_no'] == true? array('title' => 'Special Part No'): null)
                );
                $tableCell[] = $html->tag('span', $data['Supplier']['name'], array('id' => "name$cur"));
                $tableCell[] = $html->tag('span', $data['Supplier']['modified'], array('class' => 'lower'));
                $tableCell[] = $data['User']['name'];
                $tableCell[] = $ajax->link($html->image('icon/edit.png', array('title' => 'edit', 'alt' => 'edit')), 'view/' . $data['Supplier']['id'],
                        array('indicator' => 'indicator', 'update' => 'content'), null, false) . '&nbsp;' .
                        $html->link($html->image('icon/supplier_user_icon.png'), array('controller' => 'its_admins', 'action' => 'view_as_supplier_user', $data['Supplier']['id']), array('id' => 'viewAsSupplier' . $cur, 'title' => 'View as Vendor user'), null, false) .
                        $this->element('javascript/confirm_link', array('id' => 'viewAsSupplier' . $cur, 'message' => "Do you want to view as \"{$data['Supplier']['name']}\" user?"));
                echo $html->tableCells($tableCell, array('class' => 'odd-cell'), array('class' => 'even-cell'));
                ?>
            <?php endforeach; ?>
    </tbody>
</table>

    <?php echo $this->element('paging'); ?>
<? endif; ?>